import request from '@/utils/request'

// 查询用户扩展信息列表
export function listUserExtend(query) {
  return request({
    url: '/campus/userExtend/list',
    method: 'get',
    params: query
  })
}

// 查询用户扩展信息详细
export function getUserExtend(userId) {
  return request({
    url: '/campus/userExtend/' + userId,
    method: 'get'
  })
}

// 查询用户扩展信息详细（包含关联信息）
export function getUserExtendDetail(userId) {
  return request({
    url: '/campus/userExtend/detail/' + userId,
    method: 'get'
  })
}

// 根据学号查询学生
export function getStudentByNumber(schoolId, studentNumber) {
  return request({
    url: '/campus/userExtend/student',
    method: 'get',
    params: { schoolId, studentNumber }
  })
}

// 根据工号查询教师
export function getTeacherByNumber(schoolId, teacherNumber) {
  return request({
    url: '/campus/userExtend/teacher',
    method: 'get',
    params: { schoolId, teacherNumber }
  })
}

// 查询学校的用户列表
export function getUsersBySchool(schoolId, userType) {
  return request({
    url: '/campus/userExtend/school',
    method: 'get',
    params: { schoolId, userType }
  })
}

// 查询班级的学生列表
export function getStudentsByClass(classId) {
  return request({
    url: '/campus/userExtend/class',
    method: 'get',
    params: { classId }
  })
}

// 查询已绑定微信的用户
export function getWechatBoundUsers(schoolId) {
  return request({
    url: '/campus/userExtend/wechatBound',
    method: 'get',
    params: { schoolId }
  })
}

// 查询用户统计信息
export function getUserStatistics(schoolId) {
  return request({
    url: '/campus/userExtend/statistics',
    method: 'get',
    params: { schoolId }
  })
}

// 新增用户扩展信息
export function addUserExtend(data) {
  return request({
    url: '/campus/userExtend',
    method: 'post',
    data: data
  })
}

// 修改用户扩展信息
export function updateUserExtend(data) {
  return request({
    url: '/campus/userExtend',
    method: 'put',
    data: data
  })
}

// 删除用户扩展信息
export function delUserExtend(userId) {
  return request({
    url: '/campus/userExtend/' + userId,
    method: 'delete'
  })
}

// 批量更新用户学校信息
export function updateUserSchoolBatch(userIds, schoolId) {
  return request({
    url: '/campus/userExtend/updateSchoolBatch',
    method: 'put',
    params: {
      userIds: userIds.join(','),
      schoolId
    }
  })
}

// 校验学号是否唯一
export function checkStudentNumberUnique(schoolId, studentNumber, userId) {
  return request({
    url: '/campus/userExtend/checkStudentNumberUnique',
    method: 'post',
    data: { schoolId, studentNumber, userId }
  })
}

// 校验工号是否唯一
export function checkTeacherNumberUnique(schoolId, teacherNumber, userId) {
  return request({
    url: '/campus/userExtend/checkTeacherNumberUnique',
    method: 'post',
    data: { schoolId, teacherNumber, userId }
  })
}

// 导出用户扩展信息
export function exportUserExtend(query) {
  return request({
    url: '/campus/userExtend/export',
    method: 'post',
    data: query
  })
} 